package com.dycn.posdashboard.dbhelper;

import java.sql.SQLFeatureNotSupportedException;
import java.util.Map;
import java.util.logging.Logger;

import org.springframework.jdbc.datasource.lookup.AbstractRoutingDataSource;


public class DynamicDataSource extends AbstractRoutingDataSource {

	private Map<String,XBasicDataSource> targetDataSources=null;
	
    protected Object determineCurrentLookupKey() {
    	
    	String dbSourcKey=DbContextHolder.getDbSource();
    	System.out.println("determineCurrentLookupKey dbSourcKey:"+dbSourcKey);
        return DbContextHolder.getDbSource();
    }
    
    public Map<String,XBasicDataSource> getTargetDataSources(){
    
    	return this.targetDataSources;
    }
//  
    @Override
    public void setTargetDataSources(Map targetDataSources){
        super.setTargetDataSources(targetDataSources);
        this.targetDataSources=targetDataSources;
    }

    @Override
	public Logger getParentLogger() throws SQLFeatureNotSupportedException {
		// TODO Auto-generated method stub
		return null;
	}

 
}